//
//  UIBarButtonItem.swift
//  maopu
//
//  Created by 黄海波 on 2017/4/19.
//  Copyright © 2017年 maopu. All rights reserved.
//

import UIKit

extension UIBarButtonItem {
    
    
    
    //MARK: 设置图片UIBarButton
    class func setImgBarButton(imgName:String ,  action:Selector , target:Any?) -> UIBarButtonItem{
        let barImage = UIImage(named: imgName)!.withRenderingMode(UIImageRenderingMode.alwaysOriginal)
        let barButton = UIBarButtonItem(image: barImage, style: UIBarButtonItemStyle.done, target: target, action: action)
        return barButton
    }
    //MARK: 设置文字类型UIBarButton
    class func setTextBarButton(_ title:String , action:Selector , target:Any) -> UIBarButtonItem {
        let customFont:UIFont = UIFont.LightDefaultFont(13)
        let barButton = UIBarButtonItem(title: title, style: .plain, target: target, action: action)
        barButton.setTitleTextAttributes([NSFontAttributeName:customFont , NSForegroundColorAttributeName:UIColor(red: 59/255, green: 58/255, blue: 56/255, alpha: 1.0)], for: UIControlState.normal)
        return barButton
    }
    
    //MARK: 设置文字类型UIBarButton
    class func setTextBarButton(_ title:String , action:Selector , target:Any , color:UIColor) -> UIBarButtonItem {
        let customFont:UIFont = UIFont.LightDefaultFont(13)
        let barButton = UIBarButtonItem(title: title, style: .plain, target: target, action: action)
        barButton.setTitleTextAttributes([NSFontAttributeName:customFont , NSForegroundColorAttributeName:color], for: UIControlState.normal)
        return barButton
    }
    
    //MARK: 设置图片UIBarButton
    class func setBackBarButton(action:Selector , target:Any?) -> UIBarButtonItem{
        return UIBarButtonItem.setImgBarButton(imgName: "back", action: action, target: target)
    }
}
